<template>
	<view class="mydetail-body">
		<view class="tn-flex tn-flex-direction-column tn-padding-sm">
			<view class="tn-margin-bottom-sm">
				通知标题
			</view>
			<view class="tn-bg-white">
				<tn-input type="text" placeholder="请输入标题(必填)" border v-model="title"></tn-input>
			</view>
		</view>
		<view class="tn-flex tn-flex-direction-column tn-padding-sm">
			<view class="tn-margin-bottom-sm">
				发送班级<text style="color: #666666;">（至少选择一个）</text>
			</view>
			<view class="">
				<tn-radio-group v-model="classesId">
				  <tn-radio v-for="(item, index) in classList" :key="index" :name="item.classId">{{item.className}}</tn-radio>
				</tn-radio-group>
			</view>
		</view>
		<view class="tn-flex tn-flex-direction-column tn-padding-sm">
			<view class="tn-margin-bottom-sm">
				通知内容
			</view>
			<view class="tn-bg-white height-200">
				  <tn-input type="textarea" placeholder="请输入消息内容(必填)" v-model="content"></tn-input>
			</view>
		</view>
		<view class="login__body__item__button" hover-class="tn-hover" :hover-stay-time="150" @click="fabuFunction">发布</view>
		
			<tn-toast
			  ref="toast"
			></tn-toast>
	</view>
</template>

<script>
	
		export default {
			name: 'fabutongzhi',
			data(){
				return {
					avatarUrl: 'https://tnuiimage.tnkjapp.com/blogger/blogger_beibei.jpg',
					tongzhiList: [1,2,3,4,5,6,6,432,123,43,54,324,432,543,23,4235,5325,324,3525,543,543,23,43,325,32,43],
					options: [
					  {
						icon: 'delete',
						style: {
						  backgroundColor: '#E83A30',
						  width: '80rpx',
						  height: '80rpx',
						  margin: '0 12rpx',
						  borderRadius: '100rpx'
						}
					  }
					],
					classList:[
					],
					title: '',
					classesId: '',
					content: '',
				}
			},
			mounted() {
				this.getClasss()
			},
			methods:{
				deleteTongzhi(item){
					
				},
				async fabuFunction(){
					console.log(this.title)
					if(!this.title){
						this.$refs.toast.show({
						  title: '',
						  content: '请填写消息标题',
						  icon: '',
						  image: '',
						  duration: 1000
						})
						return;
					}
					if(!this.classesId){
						this.$refs.toast.show({
						  title: '',
						  content: '请选择发送班级',
						  icon: '',
						  image: '',
						  duration: 1000
						})
						return;
					}
					if(!this.content){
						this.$refs.toast.show({
						  title: '',
						  content: '请填写消息内容',
						  icon: '',
						  image: '',
						  duration: 1000
						})
						return;
					}
					
					let cresult = await this.contentCheck.checkRequest(2, this.title+this.content)
					if(!cresult){
						return
					}
					let userInfo = uni.getStorageSync('userInfo')
					this.request({
						url: '/sysNotice/add',
						method: 'post',
						params: {
							title: this.title,
							content: this.content,
							organizationId: userInfo.orgId,
							classesId: this.classesId
						}
					}).then(res => {
						if(res.code == 200){
							  uni.navigateBack();
						}else{
							this.$refs.toast.show({
								title: '',
								content: res.message || '发布失败',
								icon: '',
								image: '',
								duration: 1000
							})
						}
					})
				},
				getClasss(){
					  this.request({
						url: '/ClassDynamic/GetMyAuthClassList',
						method: 'get',
					  }).then(res => {
						  if(res.code == 200){
							  this.classList = res.data.map(item => {
								  item.isselect = false;
								  return item;
							  })
						  }
					  })
				},
			},
		}
</script>

<style lang="scss" scoped>
	.mydetail-body{
		min-height: 100vh;
		background-color: rgba(255, 255, 255, 1);
		overflow-y: auto;
		padding: 26rpx;
	}
	.tn-swipe-action-item{
		border-bottom: 1px solid #dddddd;
	}
  .fabu__btn{
	  position: fixed;
	  bottom: 30%;
	  right: 10px;
  }
  .height-200{
	  height: 400rpx;
	  border: 1px solid #dddddd;
	  overflow-y: auto;
  }
 .login__body__item__button {
 		     width: 90%;
 		     height: 77rpx;
 		     text-align: center;
 		     font-size: 31rpx;
 		     font-weight: bold;
 		     line-height: 77rpx;
 		     letter-spacing: 1em;
 		     text-indent: 1em;
 		     border-radius: 39rpx;
 			 position: absolute;
 			 bottom: env(safe-area-inset-bottom);
 			 left: 5%;
 			 background-color: #79CF67;
 			 color:#fff
 	}
</style>